package com.proposition.web.exam;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.proposition.commons.exam.result.Result;
import com.proposition.commons.exam.result.ResultUtil;
import com.proposition.commons.model.*;
import com.proposition.support.annotation.LogAnnotation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author: 陈玉林
 * @modifiedBy:
 * @date: Create In 16:59 2017/11/6
 * @description: 试题参数设置
 */
@Controller
@RequestMapping("/exam/param/set")
public class ExamParamSetController {
    /**
     * @author: 陈玉林
     * @date: 2017/11/6 17:03
     * @description: 穴位定位-成人穴位
     */
    @LogAnnotation(moduleName = "系统管理", operate = "试题参数设置")
    @ResponseBody
    @PutMapping("/put/acupointLocationAdult")
    public Result setParam(ExamParamAcupointLocationAdult examParam) {
        List<ExamParamAcupointLocationAdult> list = examParam.selectList(new EntityWrapper());
        //没有数据就查询，有数据就更新
        if (list.isEmpty()) {
            examParam.insert();
        }else{
            examParam.update(new EntityWrapper());
        }
        return ResultUtil.sucess();
    }

    /**
     * @author: 陈玉林
     * @date: 2017/11/7 9:46
     * @description: 穴位定位-儿科穴位
     */
    @LogAnnotation(moduleName = "系统管理", operate = "试题参数设置")
    @ResponseBody
    @PutMapping("/put/acupointLocationPediatric")
    public Result setParam(ExamParamAcupointLocationPediatric examParam) {
        List<ExamParamAcupointLocationPediatric> list = examParam.selectList(new EntityWrapper());
        //没有数据就查询，有数据就更新
        if (list.isEmpty()) {
            examParam.insert();
        }else{
            examParam.update(new EntityWrapper());
        }
        return ResultUtil.sucess();
    }
    /**
     *@author: 陈玉林 
     *@date: 2017/11/7 10:39
     *@description: 单项手法-儿科手法、成人手法、触诊诊断
     */
    @LogAnnotation(moduleName = "系统管理", operate = "试题参数设置")
    @ResponseBody
    @PutMapping("/put/singlePloyCEC")
    public Result setParam(ExamParamSinglePloyCEC examParam) {
        List<ExamParamSinglePloyCEC> list = examParam.selectList(new EntityWrapper());
        //没有数据就查询，有数据就更新
        if (list.isEmpty()) {
            examParam.insert();
        }else{
            examParam.update(new EntityWrapper());
        }
        return ResultUtil.sucess();
    }
    /**
     *@author: 陈玉林 
     *@date: 2017/11/7 10:55
     *@description: 成套手法-妇、伤、儿、内科
     */
    @LogAnnotation(moduleName = "系统管理", operate = "试题参数设置")
    @ResponseBody
    @PutMapping("/put/completePloyFSEN")
    public Result setParam(ExamParamCompletePloyFSEN examParam) {
        List<ExamParamCompletePloyFSEN> list = examParam.selectList(new EntityWrapper());
        //没有数据就查询，有数据就更新
        if (list.isEmpty()) {
            examParam.insert();
        }else{
            examParam.update(new EntityWrapper());
        }
        return ResultUtil.sucess();
    }
    /**
     *@author: 陈玉林 
     *@date: 2017/11/7 11:09
     *@description: 问答题-腧穴
     */
    @LogAnnotation(moduleName = "系统管理", operate = "试题参数设置")
    @ResponseBody
    @PutMapping("/put/wendaAcupoint")
    public Result setParam(ExamParamWendaAcupoint examParam) {
        List<ExamParamWendaAcupoint> list = examParam.selectList(new EntityWrapper());
        //没有数据就查询，有数据就更新
        if (list.isEmpty()) {
            examParam.insert();
        }else{
            examParam.update(new EntityWrapper());
        }
        return ResultUtil.sucess();
    }
    /**
     *@author: 陈玉林
     *@date: 2017/11/7 11:19
     *@description: 问答题-内科、伤科、妇科、儿科、触诊
     */
    @LogAnnotation(moduleName = "系统管理", operate = "试题参数设置")
    @ResponseBody
    @PutMapping("/put/wendaFSEN")
    public Result setParam(ExamParamWendaFSENC examParam) {
        List<ExamParamWendaFSENC> list = examParam.selectList(new EntityWrapper());
        //没有数据就查询，有数据就更新
        if (list.isEmpty()) {
            examParam.insert();
        }else{
            examParam.update(new EntityWrapper());
        }
        return ResultUtil.sucess();
    }
}
